<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
    <title>组件的嵌套</title>
</head>
<body>
<div id="app"></div>

<!--script-->
<script src="lib/react/react.js"></script>
<script src="lib/react/JSXTransformer.js"></script>
<script type="text/jsx">
    var MessageBox = React.createClass({
        render: function () {
            var submessage = [];
            for (var i = 0; i < 10; i++) {
                submessage.push(
                    <SubMessage key={'submessage'+i}/> //每个组件必须有一个key
                )
            }

            return (
                <div>
                    <h1>你好世界！！！</h1>
                    {submessage}
                </div>
            );
        }
    });

    var SubMessage = React.createClass({
        render: function () {
            return (
                <div>
                    <h3>写代码很有意思</h3>
                    <Footer/>
                </div>
            )
        }
    });

    var Footer = React.createClass({
        render: function () {
            return (
                <div>
                    <small>因为我在用代码创造</small>
                </div>
            )
        }
    })


    React.render(<MessageBox/>,
        document.getElementById("app"),
        function () {
            console.log("渲染完成了")
        });
</script>
</body>
</html>
